package io.gitee.wminyu.day06;

import org.junit.Test;

import java.security.Key;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Set;

public class ChouJiang {

    int count=10;
    public String random(int num){
        Map<Integer,String>map = new HashMap<>();
        map.put(1,"1");map.put(2,"2");
        map.put(3,"3");map.put(4,"4");
        map.put(5,"5");map.put(6,"6");
        map.put(7,"7");map.put(8,"8");
        map.put(9,"9");map.put(10,"10");
            //遍历取值
//        Set<Integer> keys = map.keySet();
//        for (Integer key : keys){
//            Set<Map.Entry<Integer, String>> entries = map.entrySet();
//        }
//        for (Map.Entry<Integer, String> entry : map.entrySet()){
//            System.out.println("key："+entry.getKey()+"value:"+entry.getValue());
//        }
        while (count>0){
            Integer[]keys = map.keySet().toArray(new Integer[0]);
            Random random = new Random();
            Integer randomKey = keys[random.nextInt(keys.length)];
            String randomValue = map.get(randomKey);
            System.out.println(map.get(randomKey));
            map.remove(randomKey);
            count--;
        }
        return map.get(num);
    }
    @Test
    public void test(){
        System.out.println(random(2));
    }

}
